n = int(input())
rows = list(map(int, input().split()))
cols = list(map(int, input().split()))
board = [[0 for _ in range(n)] for _ in range(n)]
parent = [0 for _ in range(n * n)]


def isValid():
    # 判断每一行
    for i in range(n):
        cnt = 0
        for j in range(n):
            if board[i][j]:
                cnt += 1
        if cnt != cols[i]:
            return False
    # 每一列
    for j in range(n):
        cnt = 0
        for i in range(n):
            if board[i][j]:
                cnt += 1
        if cnt != rows[j]:
            return False
    return True


roads = []


def dfs(index):
    if index == n * n - 1:
        if isValid():
            p = n * n - 1
            while p:
                roads.append(str(p))
                p = parent[p]
            return True
        return False
    x = index // n
    y = index % n
    for next_x, next_y in [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]:
        if next_x < 0 or next_x >= n: continue
        if next_y < 0 or next_y >= n: continue
        if board[next_x][next_y]: continue
        board[next_x][next_y] = 1
        next_index = next_x * n + next_y
        parent[next_index] = index
        if dfs(next_index):
            return True
        board[next_x][next_y] = 0
        parent[next_index] = 0
    return False


board[0][0] = 1
dfs(0)
print(0, end=' ')
print(" ".join(roads[::-1]))
